<template>
    <div class="heart">
      <el-breadcrumb separator="">
        <el-breadcrumb-item :to="{ path: '/dataReport' }">数据报表</el-breadcrumb-item>
        <el-breadcrumb-item
        ><a></a></el-breadcrumb-item
      >
      </el-breadcrumb>
      <div class="search">
        <div style="width: 240px">
            <el-date-picker
            v-model="timeRange"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
          />
        </div>     
        <el-input v-model="companyName" style="width:200px;"  placeholder="公司名称">

        </el-input>
        <el-button type="primary" style="width: 80px;">查询</el-button>
      </div>
      <el-card style="height: 70px; margin-top: 20px; position:relative;" shadow="hover">
        <el-button type="primary" style="width: 100px;">添加企业计算</el-button>
      </el-card>
      <el-table
      ref="multipleTableRef"
      :data="tableData"
      style="width: 100%; margin-top: 20px"
      @sort-change="handleSort"
    >
    <el-table-column prop="phAverage" label="企业名称" />
    <el-table-column prop="chemistryAverage" label="排污类型" />
    <el-table-column prop="instantAverage" label="开始时间" sortable/>
    <el-table-column prop="instantAverage" label="结束时间" />
    <el-table-column prop="instantOutput" label="当量值" />
    <el-table-column prop="createTime" label="费用" />
    <el-table-column label="操作" >
        <template #default="scope">
            <el-button type="danger">禁用</el-button>
            <el-button type="danger">删除</el-button>
        </template>
    </el-table-column>
    </el-table>
    <div class="pagination">
      <Pagination v-model:page="page"  :total="total" @pagination=""/>
    </div>
    </div>
      
  </template>
  <script lang="ts" setup>
  import { ref, watch, onMounted, reactive,  } from 'vue'
  import Pagination from '../../components/Pagination.vue'
    let timeRange =  ref('')
    let timeScale = ref(1)
    let dataType = ref(1)
    const options = [
  {
    value: 1,
    label: '每月数据',
  },
  {
    value: 2,
    label: '每天数据',
  },
  {
    value: 3,
    label: '小时数据',
  },
]
    onMounted(()=>{
      console.log(tableData.value)
    })
    const tableData = ref([
      {
          "id":1,
          "phAverage": "米鹰讯1",
          "chemistryAverage": "污水",
          "chemistryOutput": "2024-05-09",
          "instantAverage": "2024-05-10",
          "instantOutput": "7771",
          "createTime": "100043",
        },
        {
          "id":2,
          "phAverage": "米鹰讯2",
          "chemistryAverage": "污气",
          "chemistryOutput": "2024-05-08",
          "instantAverage": "2024-05-11",
          "instantOutput": "7651",
          "createTime": "132000",
        },
        {
          "id":3,
          "phAverage": "米鹰讯3",
          "chemistryAverage": "污气",
          "chemistryOutput": "2024-05-07",
          "instantAverage": "2024-05-12",
          "instantOutput": "7241",
          "createTime": "100430",
        },
        {
          "id":4,
          "phAverage": "米鹰讯4",
          "chemistryAverage": "污水",
          "chemistryOutput": "2024-05-06",
          "instantAverage": "2024-05-13",
          "instantOutput": "7421",
          "createTime": "100240",
        },
        {
          "id":5,
          "phAverage": "米鹰讯5",
          "chemistryAverage": "污水",
          "chemistryOutput": "2024-05-05",
          "instantAverage": "2024-05-14",
          "instantOutput": "7431",
          "createTime": "103400",
        },
        {
          "id":6,
          "phAverage": "米鹰讯6",
          "chemistryAverage": "污气",
          "chemistryOutput": "2024-05-04",
          "instantAverage": "2024-05-15",
          "instantOutput": "7431",
          "createTime": "100420",
        },
        {
          "id":7,
          "phAverage": "米鹰讯7",
          "chemistryAverage": "污气",
          "chemistryOutput": "2024-05-03",
          "instantAverage": "2024-05-16",
          "instantOutput": "7761",
          "createTime": "108700",
        },
        {
          "id":8,
          "phAverage": "米鹰讯8",
          "chemistryAverage": "污水",
          "chemistryOutput": "2024-05-02",
          "instantAverage": "2024-05-17",
          "instantOutput": "7151",
          "createTime": "102500",
        },
        {
          "id":9,
          "phAverage": "米鹰讯9",
          "chemistryAverage": "污气",
          "chemistryOutput": "2024-05-01",
          "instantAverage": "2024-05-18",
          "instantOutput": "7641",
          "createTime": "106700",
        },
        {
          "id":10,
          "phAverage": "米鹰讯10",
          "chemistryAverage": "污水",
          "chemistryOutput": "2024-04-30",
          "instantAverage": "2024-05-19",
          "instantOutput": "7161",
          "createTime": "100760",
        },
    ])
    interface Instrument {
      id: number,
      companyName: string,
      outputName: string,
      instrumentName: string,
      instrumentMIN: string,
      password: string,
      isUsing: boolean
    }
    let selected = ref<number[]>([])
    const handleSelectionChange = (a:Instrument[])=>{
      selected.value = [];
      a.forEach((row:Instrument)=>{
        selected.value.push(row.id)
      })
      console.log(selected.value)
    }
  
    let handleSort = (data: {column: any, prop: string, order: any })=>{
      console.log(data)
    }
    let currentPage = ref(1)
    let pageSize = ref(10)
    let total = ref(100)
    let page = ref(1)

  </script>
  <style>
    .heart{
      width: 95%;
      margin: 20px auto;
    }
    .search{
      margin-top: 50px;
      display: flex;
      justify-content: space-around;
    }
    .pagination{
      margin-top: 40px;
      display: flex;
      justify-content: center;
    }
  </style>